package org.linphone.sub.treeview;

import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;

import org.linphone.R;

import me.texy.treeview.TreeNode;
import me.texy.treeview.base.CheckableNodeViewBinder;

/**
 * Created by Xiang on 2018/5/15.
 */

public class FirstItemList extends CheckableNodeViewBinder {
	//名称内容
	private TextView item_name;
	//选择框
	private CheckBox item_choice;
	//初始化数据
	public FirstItemList(View itemView) {
		super(itemView);
		item_name = (TextView) itemView.findViewById(R.id.item_name);
		item_choice = (CheckBox) itemView.findViewById(R.id.item_choice);
	}
	//获取选择的内容
	@Override
	public int getCheckableViewId() {
		return R.id.item_choice;
	}
	//获取界面Id
	@Override
	public int getLayoutId() {
		return R.layout.item_list;
	}
	//绑定View
	@Override
	public void bindView(TreeNode treeNode) {
		String[] all = treeNode.getValue().toString().split("[$]");
		switch (all[2].length()){
			case 1:
				item_name.setText(all[0]+"  "+all[3]+"    "+"SIP号：000"+all[2]);
				break;
			case 2:
				item_name.setText(all[0]+"  "+all[3]+"    "+"SIP号：00"+all[2]);
				break;
			case 3:
				item_name.setText(all[0]+"  "+all[3]+"    "+"SIP号：0"+all[2]);
				break;
			case 4:
				item_name.setText(all[0]+"  "+all[3]+"    "+"SIP号："+all[2]);
				break;

		}

	}

}
